package com.guchenbo.submit;

import org.apache.spark.deploy.SparkSubmit;
import org.junit.Test;

public class ParsePrimaryResource {

  @Test
  public void appJarLocal() {
    // app jar
    String[] submitArgs = {"--class", "org.apache.spark.examples.SparkPi", "--master", "local",
        "-v",
        "/Users/guchenbo/opt/install/spark-2.4.7-bin-hadoop2.7/examples/jars/spark-examples_2.11-2.4.7.jar",
        "this is arg"};
    SparkSubmit.main(submitArgs);
  }

  @Test
  public void appJarYarn() {
    // app jar
    // set HADOOP_CONF_DIR
    String[] submitArgs = {"--class", "org.apache.spark.examples.SparkPi", "--master", "yarn",
        "--deploy-mode", "cluster", "-v",
        "/Users/guchenbo/opt/install/spark-2.4.7-bin-hadoop2.7/examples/jars/spark-examples_2.11-2.4.7.jar",
        "this is arg"};
    SparkSubmit.main(submitArgs);
  }

  @Test
  public void pythonFileYarn() {
    // python file
    // set HADOOP_CONF_DIR
    String[] submitArgs = {"--master", "yarn", "--deploy-mode", "cluster", "-v",
        "/Users/guchenbo/opt/install/spark-2.4.7-bin-hadoop2.7/examples/src/main/python/pi.py",
        "this is arg"};
    SparkSubmit.main(submitArgs);
  }

  @Test
  public void rFile() {
    // R file
    String[] submitArgs = {"--master", "local",
        "/Users/guchenbo/opt/install/spark-2.4.7-bin-hadoop2.7/examples/src/main/r/dataframe.R",
        "this is arg"};
    SparkSubmit.main(submitArgs);
  }
}
